package com.sds.sweng.swat.miplatform.ui.design.parts.area.sub;

import org.eclipse.draw2d.FlowLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;

import com.sds.sweng.swat.miplatform.ui.design.models.area.sub.PagingSubArea;

public class PagingSubAreaPart extends SubAreaPart {

	protected IFigure createFigure() {
		Label f = (Label) super.createFigure();
		drawChildren(f);

		return f;
	}

	private void drawChildren(Label parent) {
		clearChildren(parent);

		FlowLayout layout = new FlowLayout();
		layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
		layout.setMinorSpacing(5);
		parent.setLayoutManager(layout);

		PagingSubArea area = (PagingSubArea) getModel();
		boolean paging = area.isPaging();

		if (paging) {
			parent.setText("");

			Label pagingLabel = new Label("1 2 3 4 5 ");
			parent.add(pagingLabel);
		} else {
			parent.setText(area.getName());
		}
	}

	protected void createEditPolicies() {

	}

	protected void refreshVisuals() {
		drawChildren((Label) getFigure());
	}

}
